package net.borlis.processor.dao.entity;

import net.borlis.processor.dao.entity.common.AuditedEntity;
import net.borlis.processor.dao.entity.common.BaseEntity;
import net.borlis.processor.enumerated.TaskType;

import javax.persistence.*;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * Created by borlis on 24.12.2014.
 */
@Entity
@Table(name = "abstract_task")
public class AbstractTaskEntity extends BaseEntity implements AuditedEntity {

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private BigInteger id;

    @Column(name = "name")
    private String name;

    @ManyToOne
    @JoinColumn(name = "fk_user_id", nullable = false)
    private UserEntity user;

    @Column(name = "uuid", nullable = false)
    @org.hibernate.annotations.Type(type = "org.hibernate.type.PostgresUUIDType")
    private UUID uuid;

    @Basic
    @Column(name = "type", nullable = false)
    @Enumerated(EnumType.STRING)
    private TaskType type;

    @OneToMany(mappedBy = "abstractTask")
    private List<AbstractTaskParameterEntity> parameters;

    public AbstractTaskEntity() {
        super();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public UUID getUuid() {
        return uuid;
    }

    public void setUuid(UUID uuid) {
        this.uuid = uuid;
    }

    public TaskType getType() {
        return type;
    }

    public void setType(TaskType type) {
        this.type = type;
    }

    public BigInteger getId() {
        return id;
    }

    public void setId(BigInteger id) {
        this.id = id;
    }

    public List<AbstractTaskParameterEntity> getParameters() {
        if (parameters == null) {
            parameters = new ArrayList<>();
        }
        return parameters;
    }

    public void setParameters(List<AbstractTaskParameterEntity> parameters) {
        this.parameters = parameters;
    }

    public UserEntity getUser() {
        return user;
    }

    public void setUser(UserEntity user) {
        this.user = user;
    }
}
